package fx.iog.feed;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import fx.iog.gen.R;

@SuppressLint("NewApi")
public class FragmentFeedMusic extends Fragment {

	private CheckBox ch_feed_reggae;
	private static CheckBox ch_feed_tudo;
	private CheckBox ch_feed_rock;
	private CheckBox ch_feed_rap;
	private CheckBox ch_feed_pop;
	private CheckBox ch_feed_pagode;
	private CheckBox ch_feed_funk;
	private CheckBox ch_feed_mpb;
	private CheckBox ch_feed_forro;
	private CheckBox ch_feed_sertanejo;
	private CheckBox ch_feed_eletronica;
	private CheckBox ch_feed_axe;
	private CheckBox ch_feed_samba;
	private static List<CheckBox> lista = new ArrayList<CheckBox>();

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		super.onCreateView(inflater, container, savedInstanceState);

		View view = inflater.inflate(R.layout.fragment_selectfeed_music,
				container, false);

		ch_feed_reggae = (CheckBox) view.findViewById(R.id.ch_feed_reggae);
		ch_feed_rap = (CheckBox) view.findViewById(R.id.ch_feed_rap);
		ch_feed_rock = (CheckBox) view.findViewById(R.id.ch_feed_rock);
		ch_feed_pop = (CheckBox) view.findViewById(R.id.ch_feed_pop);
		ch_feed_pagode = (CheckBox) view.findViewById(R.id.ch_feed_pagode);
		ch_feed_forro = (CheckBox) view.findViewById(R.id.ch_feed_forro);
		ch_feed_sertanejo = (CheckBox) view
				.findViewById(R.id.ch_feed_sertanejo);
		ch_feed_axe = (CheckBox) view.findViewById(R.id.ch_feed_axe);
		ch_feed_samba = (CheckBox) view.findViewById(R.id.ch_feed_samba);
		ch_feed_funk = (CheckBox) view.findViewById(R.id.ch_feed_restaurante);
		ch_feed_eletronica = (CheckBox) view
				.findViewById(R.id.ch_feed_eletronica);
		ch_feed_mpb = (CheckBox) view.findViewById(R.id.ch_feed_mpb);
		ch_feed_tudo = (CheckBox) view.findViewById(R.id.ch_feed_tudo_music);

		lista.add(ch_feed_reggae);
		lista.add(ch_feed_rap);
		lista.add(ch_feed_rock);
		lista.add(ch_feed_pop);
		lista.add(ch_feed_pagode);
		lista.add(ch_feed_forro);
		lista.add(ch_feed_sertanejo);
		lista.add(ch_feed_axe);
		lista.add(ch_feed_samba);
		lista.add(ch_feed_funk);
		lista.add(ch_feed_eletronica);
		lista.add(ch_feed_mpb);
		lista.add(ch_feed_tudo);

		return view;
	}

	public static void marcarTodos() {

		if (ch_feed_tudo.isChecked()) {
			for (int i = 0; i < lista.size(); i++) {
				lista.get(i).setChecked(true);
			}

		} else {
			for (int i = 0; i < lista.size(); i++) {
				lista.get(i).setChecked(false);
			}
		}
	}
}
